// import { createStore } from 'vuex'

// export default createStore({
//   state: {
//   },
//   getters: {
//   },
//   mutations: {
//   },
//   actions: {
//   },
//   modules: {
//   }
// })

import { defineStore } from "pinia"

export const useAuthStore = defineStore('auth', {
  state: () => ({
    permissions: [], // 初始为空数组
    user: null,
  }),

  actions: {
    // 登录成功后设置权限
    setPermissions(permissions) {
      this.permissions = permissions
    },

    // 可选：清除权限（退出登录时）
    clearPermissions() {
      this.permissions = []
      this.user = null
    },

    // 检查是否有某个权限
    hasPermission(permission) {
      return this.permissions.includes(permission)
    }
  }
})
